package edu.zqu.collegeField.framework.activiti.service;


import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

public class ActivitiBusinessKey extends ActivitiBase {

       //使用任务ID，查询businessKey
    public static String getBusinessKey(String taskId) {

        //1.
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        //2.使用任务ID，获取实例ID

        String processInstanceId = task.getProcessInstanceId();

        //3.使用流程实例，查询

        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();

        //4.使用流程实例对象获取BusinessKey
        String businessKey = pi.getBusinessKey();
        System.out.println("业务ID:" + businessKey);
        return businessKey;
    }
}
